import { IproFormProps } from '@/components/ProForm';

export const translate = function (
  json: IproFormProps<any>,
  server: Record<string, any>,
): IproFormProps<any> {
  const jsonObj: IproFormProps<any> = JSON.parse(JSON.stringify(json));
  (jsonObj.items || []).forEach((item) => {
    const parameter = Object.assign(
      item.parameter || {},
      server[item.type + item.parameter?.name]?.parameter || {},
    );
    item = Object.assign(
      item || {},
      server[item.type + item.parameter?.name] || {},
    );
    item.parameter = parameter;
  });
  jsonObj.formParameter = Object.assign(
    jsonObj.formParameter,
    server.formParameter || {},
  );
  jsonObj.actionParameter = server.actionParameter;
  console.log(jsonObj);
  return jsonObj;
};
